SELECT DISTINCT 
                      SO2.TABLE_CATALOG, SO2.TABLE_SCHEMA, SO2.TABLE_NAME, sysindexes.name AS CONSTRAINT_NAME, SO2.COLUMN_NAME, 
                      SK.keyno AS ORDINAL_POSITION, sysindexes.OrigFillFactor AS FILL_FACTOR, CASE WHEN INDEXPROPERTY(sysobjects.id, sysindexes.name, 
                      'IsUnique') = 1 THEN 'UNIQUE' ELSE 'NON-UNIQUE' END AS INDEX_TYPE, INDEXPROPERTY(sysobjects.id, sysindexes.name, 'IsClustered') 
                      AS IS_CLUSTERED, INDEXPROPERTY(sysobjects.id, sysindexes.name, 'IsDisabled') AS IS_DISABLED, sysindexes.status,
		CONVERT(bit, sysindexes.status) & 0x20 AS is_primary_key

FROM         sys.sysobjects AS sysobjects WITH (NOLOCK) INNER JOIN
                      sys.sysindexes AS sysindexes WITH (NOLOCK) ON sysobjects.id = sysindexes.id AND sysindexes.indid <> 0 AND sysindexes.status & 64 = 0 AND 
                      sysindexes.status & 16777216 = 0 INNER JOIN
                      sys.sysindexkeys AS SK WITH (NOLOCK) ON SK.id = sysobjects.id AND SK.indid = sysindexes.indid INNER JOIN
                      INFORMATION_SCHEMA.COLUMNS AS SO2 WITH (NOLOCK) ON SO2.ORDINAL_POSITION = SK.colid AND sysobjects.name = SO2.TABLE_NAME
WHERE SO2.TABLE_NAME <> 'sysdiagrams'
ORDER BY SO2.TABLE_CATALOG, SO2.TABLE_SCHEMA, SO2.TABLE_NAME, CONSTRAINT_NAME, ORDINAL_POSITION
